﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//请先添加引用
namespace TierApplication
{
    /// <summary>
    /// 类T_OrderPayFee。
    /// </summary>

    public partial class T_OrderPayFee
    {

        public DataSet GetPayFeeListByOrderID(string sOrderID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select a.*,(Select UserName from P_User where UserID=a.PayFeeUserID) PayFeeUserName ");
            strSql.Append(" FROM T_OrderPayFee a ");
            strSql.Append(" where OrderID ='" + sOrderID + "'");
            return DbHelperSQL.Query(strSql.ToString());
        }

        public DataSet GetPayFeeListList(string strWhere,string sPayFeeStatus)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from (select a.*,");
            strSql.Append("(Select isnull(Sum(PayFee),0) from T_OrderPayFee where OrderID=a.OrderID) OrderPayFee");
            strSql.Append(" FROM S_Order a ");
            strSql.Append(" where a.OrderType='1' " + strWhere);
            strSql.Append(" ) o ");
            if (sPayFeeStatus == "1")//已完成付款
            {
                strSql.Append(" where isnull(o.OrderActMoney,0)=isnull(o.OrderPayFee,0)  ");
            }
            if (sPayFeeStatus == "0")//未完成付款
            {
                strSql.Append(" where isnull(o.OrderActMoney,0)<>isnull(o.OrderPayFee,0)  ");
            }

            return DbHelperSQL.Query(strSql.ToString());
        }
    }
}

